package com.zzsy.carosshopprojects.util;

import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.view.View;
import android.widget.PopupWindow;

import androidx.drawerlayout.widget.DrawerLayout;

/**
 * Created by Administrator on 2020/3/17 0017.
 */

public  class PopupWindowUtils {

    private static PopupWindow popupWindow;

    public static View showPopupwindow(Context context, View view, View textView) {

          //  int width = ScreenUtils.dp2px(context, 16000);
            popupWindow = new PopupWindow(view,
                    DrawerLayout.LayoutParams.MATCH_PARENT, DrawerLayout.LayoutParams.WRAP_CONTENT, true);
            popupWindow.setFocusable(false);// 设置弹出窗体可点击
            popupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));// 实例化一个ColorDrawable颜色为半透明
            popupWindow.setOutsideTouchable(true);
            popupWindow.showAsDropDown(textView);
        return view;
    }

    public static void closePopupwindow() {
        if (popupWindow != null && popupWindow.isShowing()) {
            popupWindow.dismiss();
            popupWindow = null;
        }
    }

}
